package chaw.android.train;

import android.app.Activity;
import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class EachStationHome extends Activity {
	private ImageButton board, people, table, info;
	private String station_id, station_name;
	private TextView station, station2;
	private ImageView back;
//	ImageButton 
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
        setContentView(R.layout.each_station_home);
        back = (ImageView)findViewById(R.id.btnBack);
        board = (ImageButton)findViewById(R.id.btnShowProfile);
        people = (ImageButton)findViewById(R.id.btnShowPeople);
        table = (ImageButton)findViewById(R.id.btnShowSchedule);
        info = (ImageButton)findViewById(R.id.btnShowStationAbout);
        Intent intent = getIntent();
        station_id = intent.getExtras().get("station_id").toString();
        station_name = intent.getExtras().get("station_name").toString();
        station = (TextView)findViewById(R.id.stationName);
        station2 = (TextView)findViewById(R.id.station);
        setClickListener();
		station.setText(station_name + "역");
		station2.setText(station_name + "역");
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		for(int i = 0 ; i < 5; i++)
        	TrainTravelActivity.tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_nav2);
	}
	
	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		for(int i = 0 ; i < 5; i++)
        	TrainTravelActivity.tabHost.getTabWidget().getChildAt(i).setBackgroundResource(R.drawable.bg_nav1);
	}

	public void setClickListener(){
		back.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		board.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				ActivityGroup parentActivity = (ActivityGroup) getParent();
				Intent intent = new Intent(getBaseContext(), StationBoardActivity.class);
				intent.putExtra("station_id", station_id);
				intent.putExtra("station_name", station_name);
				((FavoriteActivity) parentActivity).startChildActivity("StationBoard", intent);
			}
		});
		people.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				ActivityGroup parentActivity = (ActivityGroup) getParent();
				Intent intent = new Intent(getBaseContext(), StationPeopleActivity.class);
				intent.putExtra("station_id", station_id);
				intent.putExtra("station_name", station_name);
				((FavoriteActivity) parentActivity).startChildActivity("StationPeople", intent);
			}
		});
		table.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				ActivityGroup parentActivity = (ActivityGroup) getParent();
				Intent intent = new Intent(getBaseContext(), StationScheduleActivity.class);
				intent.putExtra("station_id", station_id);
				intent.putExtra("station_name", station_name);
				((FavoriteActivity) parentActivity).startChildActivity("StationSchedule", intent);
			}
		});
		info.setOnClickListener(new View.OnClickListener() {			
			@Override
			public void onClick(View v) {
				ActivityGroup parentActivity = (ActivityGroup) getParent();
				Intent intent = new Intent(getBaseContext(), StationInfoActivity.class);
				intent.putExtra("station_id", station_id);
				intent.putExtra("station_name", station_name);
				((FavoriteActivity) parentActivity).startChildActivity("StationInfo", intent);
			}
		});
	}
	@Override
	public void onBackPressed() {
		finish();
	}
}
